import { requestFunc as cloudRequestFunc } from "./cloud";
import { requestFunc as baseRequestFunc } from "./base";
import type { InnerRequestConfig } from "../types/InnerRequestConfig";

// 准备请求
const requestFunc = async (
    config: InnerRequestConfig
): Promise<{
    task: UniApp.RequestTask | null;
    response: any;
}> => {
    // 判断是哪种类型的 请求
    let { cloudFunction } = config || {};
    if (cloudFunction) {
        return cloudRequestFunc(config);
    }
    return baseRequestFunc(config);
};

export { requestFunc };
